home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Basic / Visual Basic.60 / VB98 / WIZARDS / PDWIZARD / SETUP1 / GROUP.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-06-18  |  10.6 KB  |  335 lines

  1. VERSION 5.00
  2. Begin VB.Form frmGroup 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "* #"
  5.    ClientHeight    =   5250
  6.    ClientLeft      =   1095
  7.    ClientTop       =   1515
  8.    ClientWidth     =   5460
  9.    Icon            =   "group.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    LockControls    =   -1  'True
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   350
  15.    ScaleMode       =   3  'Pixel
  16.    ScaleWidth      =   364
  17.    Begin VB.DirListBox dir95Groups 
  18.       Height          =   930
  19.       Left            =   765
  20.       TabIndex        =   8
  21.       Top             =   60
  22.       Visible         =   0   'False
  23.       Width           =   3810
  24.    End
  25.    Begin VB.Frame Frame1 
  26.       Height          =   30
  27.       Left            =   105
  28.       TabIndex        =   7
  29.       Top             =   4650
  30.       Width           =   5220
  31.    End
  32.    Begin VB.CommandButton cmdCancel 
  33.       Cancel          =   -1  'True
  34.       Caption         =   "#"
  35.       Height          =   345
  36.       Left            =   2880
  37.       MaskColor       =   &H00000000&
  38.       TabIndex        =   3
  39.       Top             =   4800
  40.       Width           =   1140
  41.    End
  42.    Begin VB.CommandButton cmdContinue 
  43.       Caption         =   "#"
  44.       Default         =   -1  'True
  45.       Height          =   345
  46.       Left            =   1395
  47.       MaskColor       =   &H00000000&
  48.       TabIndex        =   2
  49.       Top             =   4800
  50.       Width           =   1140
  51.    End
  52.    Begin VB.ListBox lstGroups 
  53.       Height          =   2010
  54.       ItemData        =   "group.frx":0442
  55.       Left            =   1080
  56.       List            =   "group.frx":0449
  57.       Sorted          =   -1  'True
  58.       TabIndex        =   1
  59.       Top             =   2220
  60.       Width           =   3240
  61.    End
  62.    Begin VB.TextBox txtGroup 
  63.       Height          =   300
  64.       Left            =   1080
  65.       TabIndex        =   0
  66.       Text            =   "*"
  67.       Top             =   1410
  68.       Width           =   3270
  69.    End
  70.    Begin VB.Label lblDDE 
  71.       Height          =   225
  72.       Left            =   225
  73.       TabIndex        =   9
  74.       Top             =   1350
  75.       Visible         =   0   'False
  76.       Width           =   705
  77.    End
  78.    Begin VB.Label lblGroups 
  79.       AutoSize        =   -1  'True
  80.       Caption         =   "#"
  81.       Height          =   195
  82.       Left            =   1080
  83.       TabIndex        =   6
  84.       Top             =   1950
  85.       Width           =   105
  86.    End
  87.    Begin VB.Label lblGroup 
  88.       AutoSize        =   -1  'True
  89.       Caption         =   "#"
  90.       Height          =   195
  91.       Left            =   1080
  92.       TabIndex        =   5
  93.       Top             =   1170
  94.       Width           =   105
  95.    End
  96.    Begin VB.Label lblMain 
  97.       AutoSize        =   -1  'True
  98.       Caption         =   "#"
  99.       Height          =   195
  100.       Left            =   180
  101.       TabIndex        =   4
  102.       Top             =   165
  103.       Width           =   5100
  104.       WordWrap        =   -1  'True
  105.    End
  106. Attribute VB_Name = "frmGroup"
  107. Attribute VB_GlobalNameSpace = False
  108. Attribute VB_Creatable = False
  109. Attribute VB_PredeclaredId = True
  110. Attribute VB_Exposed = False
  111. Option Explicit
  112. Dim mstrGroup As String
  113. Dim mstrDefGroup As String
  114. Dim mstrProgramsPath As String
  115. Dim mfrm As Form
  116. Dim fPrivate As Boolean
  117. Dim fStartMenu As Boolean
  118. Private Sub cmdCancel_Click()
  119.     ExitSetup frmGroup, gintRET_EXIT
  120. End Sub
  121. Private Sub cmdContinue_Click()
  122.     mstrGroup = txtGroup.Text
  123.     If Not fCreateProgGroup() Then
  124.         '
  125.         ' Couldn't create the group. Let
  126.         ' the user try again.
  127.         '
  128.         txtGroup.SetFocus
  129.     Else
  130.         '
  131.         ' The group got created ok, so unload Choose Program Group dialog
  132.         ' and continue on with setup.
  133.         '
  134.         Unload Me
  135.     End If
  136. End Sub
  137. Private Function fCreateProgGroup() As Boolean
  138. ' Create a program group for either NT or Win95.
  139.     Dim strMsg As String
  140.     If TreatAsWin95() Then
  141.         If Not fValidFilename(mstrGroup) Then
  142.             strMsg = ResolveResString(resGROUPINVALIDGROUPNAME, "|1", CStr(gintMAX_PATH_LEN), "|2", ResolveResString(resCOMMON_INVALIDFILECHARS))
  143.             MsgFunc strMsg, vbOKOnly Or vbQuestion, gstrTitle
  144.             GoTo CGError
  145.         End If
  146.     Else
  147.         If Not fValidNTGroupName(mstrGroup) Then
  148.             strMsg = ResolveResString(resGROUPINVALIDGROUPNAME, "|1", CStr(gintMAX_GROUPNAME_LEN%), "|2", ResolveResString(resGROUPINVALIDCHARS))
  149.             MsgFunc strMsg, vbOKOnly Or vbQuestion, gstrTitle
  150.             GoTo CGError
  151.         End If
  152.             
  153.     End If
  154.     '
  155.     'Go ahead and create the main program group
  156.     '
  157.     If Not fCreateOSProgramGroup(mfrm, mstrGroup, True, , fPrivate, fStartMenu) Then
  158.         GoTo CGError
  159.     End If
  160.     fCreateProgGroup = True
  161.     Exit Function
  162. CGError:
  163.     fCreateProgGroup = False
  164. End Function
  165. Private Sub Form_Load()
  166.     '
  167.     ' Initialize localized control properties.
  168.     '
  169.     SetFormFont Me
  170.     Me.Caption = ResolveResString(resGROUPFRM, "|1", gstrAppName)
  171.     lblMain.Caption = ResolveResString(resGROUPLBLMAIN)
  172.     lblGroup.Caption = ResolveResString(resGROUPLBLGROUP)
  173.     lblGroups.Caption = ResolveResString(resGROUPLBLGROUPS)
  174.     cmdContinue.Caption = ResolveResString(resGROUPBTNCONTINUE)
  175.     cmdCancel.Caption = ResolveResString(resLOG_vbCancel)
  176.     '
  177.     ' Initialize the Program Group text box with the
  178.     ' title of the application.
  179.     '
  180.     txtGroup.Text = gstrTitle
  181.     '
  182.     ' Load the ListBox with the program manager groups.
  183.     '
  184.     If TreatAsWin95() Then
  185.         LoadW95Groups
  186.     Else
  187.         LoadProgManGroups
  188.     End If
  189.     '
  190.     ' Initialize the Program Group textbox with the
  191.     ' default group selected in the list box.
  192.     '
  193.     txtGroup.Text = lstGroups.List(lstGroups.ListIndex)
  194. End Sub
  195. Private Sub lstGroups_Click()
  196.     txtGroup.Text = lstGroups.List(lstGroups.ListIndex)
  197. End Sub
  198. Private Sub txtGroup_Change()
  199.     cmdContinue.Enabled = Len(Trim(txtGroup.Text)) > 0
  200. End Sub
  201. Sub LoadProgManGroups()
  202. ' This routine uses DDE to talk to Program Manager
  203. ' to retrieve a list of all the groups it manages.
  204. ' It should only be called if the shell is NT 3.51.
  205. ' If it is Win95 or NT4, call LoadW95Groups()
  206. ' instead.
  207. ' Special strings used in this routine.  Do not
  208. ' localize these strings.
  209.     Const strPROGMANLINKTOPIC = "ProgMan|Progman"
  210.     Const strPROGMANLINKITEM = "Progman"
  211.     Const strNDWGROUP = "Quick Access"
  212.     Dim strGroups As String
  213.     Dim strGroup As String
  214.     Dim intOffset As Integer
  215.     Dim intAnchor As Integer
  216.     Dim iGroup As Long
  217.     lblDDE.LinkTopic = strPROGMANLINKTOPIC
  218.     lblDDE.LinkItem = strPROGMANLINKITEM
  219.     lblDDE.LinkMode = 2
  220.     lblDDE.LinkRequest
  221.     On Error Resume Next
  222.     lblDDE.LinkMode = 0
  223.     '
  224.     ' The DDE call just made put the names of all the groups
  225.     ' into the caption property of the lblDDE control.
  226.     ' We want to transfer them to the list box.  They are
  227.     ' separated by vbcrlf's.
  228.     '
  229.     strGroups = lblDDE.Caption
  230.     intAnchor = 1
  231.     intOffset = InStr(intAnchor, strGroups, vbCrLf)
  232.     lstGroups.Clear
  233.     Do While intOffset > 0
  234.         strGroup = Mid(strGroups, intAnchor, intOffset - intAnchor)
  235.         '
  236.         ' Norton Desktop for Windows uses the "Quick Access" group
  237.         ' to replace program manager.  Trying to add icons to this
  238.         ' group will fail later when we perform our DDE.linkrequest.
  239.         ' Therefore, skip this group.
  240.         '
  241.         If strGroup <> strNDWGROUP Then
  242.             lstGroups.AddItem strGroup
  243.         End If
  244.         
  245.         intAnchor = intOffset + 2
  246.         intOffset = InStr(intAnchor, strGroups, vbCrLf)
  247.     Loop
  248.     '
  249.     ' The lstGroups listbox now contains a listing of all the program
  250.     ' manager groups.
  251.     '
  252.     ' Look for the default group in the list and select it.  If it's
  253.     ' not there, add it.
  254.     '
  255.     iGroup = SendMessageString(lstGroups.hwnd, LB_FINDSTRINGEXACT, -1, mstrDefGroup)
  256.     If iGroup = LB_ERR Then
  257.         '
  258.         ' The group doesn't yet exist, add it to the list.
  259.         '
  260.         lstGroups.AddItem mstrDefGroup
  261.         lstGroups.ListIndex = lstGroups.NewIndex
  262.     Else
  263.         lstGroups.ListIndex = iGroup
  264.     End If
  265. End Sub
  266. Sub LoadW95Groups()
  267. ' This routine uses the system registry to
  268. ' retrieve a list of all the subfolders in the
  269. ' \windows\start menu\programs folder.
  270. ' It should only be called if the shell is Win95
  271. ' NT4.  If it is NT 3.51, call LoadProgManGroups()
  272. ' instead.
  273.     Dim strFolder As String
  274.     Dim iFolder As Integer
  275.     mstrProgramsPath = strGetProgramsFilesPath()
  276.     strFolder = Dir(mstrProgramsPath, vbDirectory)   ' Retrieve the first entry.
  277.     lstGroups.Clear
  278.     Do While strFolder <> ""
  279.         '
  280.         ' Ignore the current directory and the encompassing directory.
  281.         '
  282.         If strFolder <> "." And strFolder <> ".." Then
  283.             '
  284.             ' Verify that we actually got a directory and not a file.
  285.             '
  286.             If (GetAttr(mstrProgramsPath & strFolder) And vbDirectory) = vbDirectory Then
  287.                 '
  288.                 ' We got a directory, add it to the list.
  289.                 '
  290.                 lstGroups.AddItem strFolder
  291.             End If
  292.         End If
  293.         '
  294.         ' Get the next subfolder in the Programs folder
  295.         '
  296.         strFolder = Dir
  297.     Loop
  298.     '
  299.     ' The lstGroups listbox now contains a listing of all the Programs
  300.     ' subfolders (the groups).
  301.     '
  302.     ' Look for the default folder in the list and select it.  If it's
  303.     ' not there, add it.
  304.     '
  305.     iFolder = SendMessageString(lstGroups.hwnd, LB_FINDSTRINGEXACT, -1, mstrDefGroup)
  306.     If iFolder = LB_ERR Then
  307.         '
  308.         ' The group doesn't yet exist, add it to the list.
  309.         '
  310.         lstGroups.AddItem mstrDefGroup
  311.         lstGroups.ListIndex = lstGroups.NewIndex
  312.     Else
  313.         lstGroups.ListIndex = iFolder
  314.     End If
  315. End Sub
  316. Public Property Get GroupName(frm As Form, strDefGroup As String, Optional fPriv As Boolean = True, Optional ByVal fStart As Boolean = False) As String
  317.     mstrDefGroup = strDefGroup
  318.     Set mfrm = frm
  319.     fPrivate = fPriv
  320.     fStartMenu = fStart
  321.     If gfNoUserInput = True Then
  322.         mstrGroup = mstrDefGroup
  323.         If Not fCreateProgGroup() Then
  324.             ExitSetup frmSetup1, gintRET_FATAL
  325.         End If
  326.     Else
  327.         Me.Show vbModal
  328.     End If
  329.     GroupName = mstrGroup
  330. End Property
  331. Private Sub txtGroup_GotFocus()
  332.     txtGroup.SelStart = 0
  333.     txtGroup.SelLength = 32767
  334. End Sub
  335.